﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TNCAddIn
{
    public partial class DefaultBudgetCenter : Form
    {
        public DefaultBudgetCenter()
        {
            InitializeComponent();

            HttpClient httpClient = new HttpClient();
            httpClient.GetBugetCenter();

            String[] _centerArray = Properties.Settings.Default.Centers.Split(',');
            this.cb_centers.Items.Clear();
            this.cb_centers.Items.AddRange(_centerArray);
            this.cb_centers.SelectedItem = Properties.Settings.Default.DefaultBudgetCenter;

            this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.DefaultBudgetCenter = this.cb_centers.SelectedItem.ToString();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            HttpClient hc = new HttpClient();
            hc.GetBugetCenter();

            String[] _centerArray = Properties.Settings.Default.Centers.Split(',');
            this.cb_centers.Items.Clear();
            this.cb_centers.Items.AddRange(_centerArray);
            this.cb_centers.SelectedItem = Properties.Settings.Default.DefaultBudgetCenter;
        }
    }
}
